//
//  MGCache.h
//  MGPublic
//
//  Created by lhongl on 2025/10/27.
//

#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

@interface MGCache : NSObject

#pragma mark - 包含
/// 包含 
/// - Parameter key: key
+ (BOOL)containsObjectForKey:(NSString *)key;

/// 包含 
/// - Parameters:
///   - key: key
///   - cacheName: 缓存name
+ (BOOL)containsObjectForKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName;

/// 包含  
/// - Parameters:
///   - key: key
///   - block: 回调
+ (void)containsObjectAsyncForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key, BOOL contains))block;

/// 包含  
/// - Parameters:
///   - key: key
///   - cacheName: 缓存name
///   - block: 回调
+ (void)containsObjectAsyncForKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName withBlock:(nullable void(^)(NSString *key, BOOL contains))block;

#pragma mark - 获取对象
/// 获取 
/// - Parameter key: key
+ (nullable id)objectForKey:(NSString *)key;

/// 获取 
/// - Parameter key: key
/// - cacheName: 缓存name
+ (nullable id)objectForKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName;

/// 获取  
/// - Parameters:
///   - key: 对象
///   - block: 回调
+ (void)objectAsyncForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key, id _Nullable object))block;

/// 获取  
/// - Parameters:
///   - key: 对象
///   - cacheName: 缓存name
///   - block: 回调
+ (void)objectAsyncForKey:(NSString *)key  withCacheName:(NSString *_Nullable)cacheName withBlock:(nullable void(^)(NSString *key, id _Nullable object))block;

#pragma mark - 存储
/// 存储 
/// - Parameters:
///   - object: 对象
///   - key: key
+ (void)setObject:(id<NSCoding>)object forKey:(NSString *)key;

/// 存储 
/// - Parameters:
///   - object: 对象
///   - key: key
///   - cacheName: 缓存name
+ (void)setObject:(id<NSCoding>)object forKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName;

/// 存储  
/// - Parameters:
///   - object: 对象
///   - key: key
///   - block: 回调
+ (void)setObjectAsnyc:(id<NSCoding>)object forKey:(NSString *)key withBlock:(nullable void(^)(void))block;

/// 存储  
/// - Parameters:
///   - object: 对象
///   - key: key
///   - cacheName: 缓存name
///   - block: 回调
+ (void)setObjectAsnyc:(id<NSCoding>)object forKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName withBlock:(nullable void(^)(void))block;

#pragma mark - 删除
/// 删除 【默认cache】
/// - Parameter key: key
+ (void)removeObjectForKey:(NSString *)key;

/// 删除 【cacheName】
/// - Parameter key: key
/// - cacheName: 缓存name
+ (void)removeObjectForKey:(NSString *)key withCacheName:(NSString *_Nullable)cacheName;

/// 删除  
/// - Parameters:
///   - key: key
///   - block: 回调
+ (void)removeObjectAsnycForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key))block;

/// 删除  
/// - Parameters:
///   - key: key
///   - cacheName 缓存name
///   - block: 回调
+ (void)removeObjectAsnycForKey:(NSString *)key
             withCacheName:(NSString *_Nullable)cacheName
                 withBlock:(nullable void(^)(NSString *key))block;

/// 删除路径所有缓存
+ (void)removeAllObjects;

/// 删除路径所有缓存
/// - Parameter block: 回调
+ (void)removeAllObjectsAsnycWithBlock:(void(^)(void))block;


///删除路径所有缓存
/// - Parameters:
/// - cacheName 缓存name
+ (void)removeAllObjectsWithCacheName:(NSString *_Nullable)cacheName;

/// 删除路径所有缓存
/// - Parameters:
///   - cacheName: 缓存name
///   - block: 回调
+ (void)removeAllObjectsAsnycWithCacheName:(NSString *_Nullable)cacheName withBlock:(void(^)(void))block;


/// 删除所有缓存 
/// - Parameter block: 回调
+ (void)removeAllCachesAsnycWithBlock:(void(^)(void))block;

@end

NS_ASSUME_NONNULL_END
